package cn.iocoder.yudao.module.system.controller.admin.mini.goodInfo.goods.dal.mysql.goods;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.controller.admin.mini.goodInfo.goods.dal.dataobject.goods.GoodsDO;
import cn.iocoder.yudao.module.system.controller.admin.mini.goodInfo.goods.controller.admin.goods.vo.GoodsExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mini.goodInfo.goods.controller.admin.goods.vo.GoodsPageReqVO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 小程序-商品 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface GoodsMapper extends BaseMapperX<GoodsDO> {

    default PageResult<GoodsDO> selectPage(GoodsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<GoodsDO>()
                .betweenIfPresent(GoodsDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(GoodsDO::getName, reqVO.getName())
                .likeIfPresent(GoodsDO::getCode, reqVO.getCode())
                .eqIfPresent(GoodsDO::getImg, reqVO.getImg())
                .eqIfPresent(GoodsDO::getType, reqVO.getType())
                .eqIfPresent(GoodsDO::getSaleNum, reqVO.getSaleNum())
                .eqIfPresent(GoodsDO::getPostalId, reqVO.getPostalId())
                .eqIfPresent(GoodsDO::getPostage, reqVO.getPostage())
                .eqIfPresent(GoodsDO::getStatus, reqVO.getStatus())
                .eqIfPresent(GoodsDO::getContent, reqVO.getContent())
                .eqIfPresent(GoodsDO::getImgInfo, reqVO.getImgInfo())
                .eqIfPresent(GoodsDO::getSpecif, reqVO.getSpecif())
                .eqIfPresent(GoodsDO::getSupplierId, reqVO.getSupplierId())
                .orderByDesc(GoodsDO::getId));
    }

    default List<GoodsDO> selectList(GoodsExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<GoodsDO>()
                .betweenIfPresent(GoodsDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(GoodsDO::getName, reqVO.getName())
                .eqIfPresent(GoodsDO::getImg, reqVO.getImg())
                .eqIfPresent(GoodsDO::getType, reqVO.getType())
                .eqIfPresent(GoodsDO::getSaleNum, reqVO.getSaleNum())
                .eqIfPresent(GoodsDO::getPostalId, reqVO.getPostalId())
                .eqIfPresent(GoodsDO::getPostage, reqVO.getPostage())
                .eqIfPresent(GoodsDO::getStatus, reqVO.getStatus())
                .eqIfPresent(GoodsDO::getContent, reqVO.getContent())
                .eqIfPresent(GoodsDO::getImgInfo, reqVO.getImgInfo())
                .eqIfPresent(GoodsDO::getSpecif, reqVO.getSpecif())
                .orderByDesc(GoodsDO::getId));
    }

}
